package com.foreveross.testproxy.test.impl;

import java.util.Random;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

public class IpConfigUtil {
	public String getUserAgent(){
    	String agent[]={
    			"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:2.0b13pre) Gecko/20110307 Firefox/4.0b13pre",
    			"Mozilla/5.0 (Windows; U; Windows NT 5.1) Gecko/20070309 Firefox/2.0.0.3",
    			"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13",
    			"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13",
    			"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)"
    	};
    	Random rdm=new Random();
		int ivalue= rdm.nextInt(agent.length);
		return agent[ivalue];
    } 
	
	public static String userIp() throws Exception {
		DefaultHttpClient httpClient = new DefaultHttpClient();
		HttpGet gh = new HttpGet("http://121.43.57.111:8015/tkip/tkip.html?size=1");
		HttpResponse response = null;
		String html = "";
		response = httpClient.execute(gh);
		HttpEntity entity = response.getEntity();
		html = EntityUtils.toString(entity);
		String tkipStr[] = html.split("\n");
//		String ip = tkipStr[0].split(":")[0];
//		String port = tkipStr[0].split(":")[1].trim();
		return html;

		// switchProxyip();
		// return getPageData(cabin);
	}
	
	public static void main(String[] args) throws Exception {
		 //System.out.println(new TianxunIPTestImpl().test(userIp()));
	}
}
